package com.dragon.pear.modules.trade.web.controller;

import com.chris.dev.base.libs.v1.http.params.NoneParam;
import com.chris.dev.base.libs.v1.http.results.ValueResult;
import com.dragon.common.spring.business.base.BaseCrudController;
import com.dragon.pear.modules.trade.dao.repository.TradeGoodsRepository;
import com.dragon.pear.modules.trade.domain.entity.TradeGoodsEntity;
import com.dragon.pear.modules.trade.service.assistants.converters.TradeGoodsConverter;
import com.dragon.pear.modules.trade.service.def.TradeGoodsService;
import com.dragon.pear.modules.trade.web.api.TradeGoodsApi;
import com.dragon.pear.modules.trade.web.model.params.create.TradeGoodsCreateParam;
import com.dragon.pear.modules.trade.web.model.params.order.TradeGoodsOrderParam;
import com.dragon.pear.modules.trade.web.model.params.search.TradeGoodsSearchParam;
import com.dragon.pear.modules.trade.web.model.params.update.TradeGoodsUpdateParam;
import com.dragon.pear.modules.trade.web.model.results.TradeGoodsResult;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.Method;
import java.lang.reflect.TypeVariable;

/**
 * @author Chris Chan
 * Create on 2025-09-30 22:06
 * Use for: 商品 接口实现
 * Explain:
 */
@RestController
@RequestMapping("trade/goods")
public class TradeGoodsController implements TradeGoodsApi, BaseCrudController<
        TradeGoodsEntity,
        TradeGoodsCreateParam,
        TradeGoodsUpdateParam,
        TradeGoodsSearchParam,
        TradeGoodsOrderParam,
        TradeGoodsResult,
        TradeGoodsRepository,
        TradeGoodsConverter,
        TradeGoodsService
        > {

    @Autowired
    TradeGoodsService tradeGoodsService;

    @Override
    public TradeGoodsService getService() {
        return tradeGoodsService;
    }

    @PostMapping({"test"})
    @Operation(summary = "test")
    public ValueResult<String> test(@RequestBody NoneParam param) {
        UserImpl c = new UserImpl();
        Class<? extends UserImpl> aClass = c.getClass();

        Method[] methods = aClass.getMethods();
        for (Method method : methods) {
            System.out.println("=================================");
            System.out.println("method = " + method.getName());
            Class<?> returnType = method.getReturnType();
            System.out.println("method-return = " + returnType.getTypeName());
            for (TypeVariable<? extends Class<?>> typeParameter : returnType.getTypeParameters()) {
                System.out.println("ret-typeParameter = " + typeParameter.getTypeName());
            }
            System.out.println("method-params =\n " );
            Class<?>[] parameterTypes = method.getParameterTypes();
            for (Class<?> parameterType : parameterTypes) {
                System.out.println("parameterType = " + parameterType.getTypeName());
            }
        }
        return ValueResult.create("test");
    }
}